package com.example.back.service.impl;

import com.example.back.model.Food;
import com.example.back.service.FoodService;
import com.example.back.mapper.FoodMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author jialily
* @description 针对表【t_food】的数据库操作Service实现
* @createDate 2022-04-29 17:21:11
*/
@Service("foodService")
//支持事务，增加，删除，更新操作单独使用 propagation = Propagation.SUPPORTS
@Transactional(propagation = Propagation.SUPPORTS,rollbackFor = Exception.class)
public class FoodServiceImpl implements FoodService{

    @Autowired
    FoodMapper foodMapper;

    public List<Food> selectAll() {
        return this.foodMapper.selectAll();
    }

    @Override
    public Food selectFood(String foodname) {
        return this.foodMapper.selectFood( foodname);
    }

    @Override
    public int updateFood(int id, String name, String fooddes) {
        return this.foodMapper.updateFood(id,name,fooddes);
    }

    @Override
    public int deleteFood(int id) {
        return this.foodMapper.deleteFood(id);
    }

    @Override
    public int insertFood(String name, String fooddes) {
        return this.foodMapper.insertFood(name,fooddes);
    }


}
